package bao2;

public class test {
    public static void main(String[] args) {
        Peolple p2 = new Teacher();
        p2.run();
        System.out.println(p2.name);
        System.out.println("++++++++++++++++");

        Peolple p1 = new Student();
        p1.run();
        System.out.println(p1.name);

        if (p1 instanceof Student) {
            Student s2 = (Student) p1;
            s2.test();
        } else {
            Teacher t2 = (Teacher) p1;
            t2.test();
        }

        System.out.println("----------------------");

        Teacher t = new Teacher();
        go(t);

        Student s = new Student();
        go(s);

    }

    public static void go(Peolple p) {

        if (p instanceof Student) {
            Student s = (Student) p;
            s.test();
        } else {
            Teacher t = (Teacher) p;
            t.test();
        }

    }
}
